<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios'

const useName = ref('')
const loginInfo = ref({
  username: '',
  password: ''
})

function getList() {
  axios.get('/api/username/submit?username=' + useName.value).then(res => {
    console.log(res);
  })
}

function submit() {
  axios.post('/api/username/list', loginInfo.value, {
    headers: {
      // 'Content-Type': 'application/json',
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then(res => {
    console.log(res);
  })
}

function uploadFile(e: any) {
  const file = e.target.files[0]
  const formData = new FormData()
  formData.append('file', file)
  axios.post('/api/upload/file', formData, {
    Headers: {
      'Content-Type': 'multipart/form-data'
    }
  }).then(res => {
    console.log(res);
  })
}
</script>

<template>
  <div class="app-container">
    <div>
      <input type="text" v-model="useName">
      <span @click="getList">搜索</span>
    </div>
    <div>
      <input type="text" v-model="loginInfo.username">
      <input type="text" v-model="loginInfo.password">
      <span @click="submit">搜索</span>
    </div>
    <div>
      <input type="file" @change="uploadFile">
    </div>
  </div>
</template>

<style scoped lang="scss">

</style>
